package com.gxp.controller;

import java.util.Iterator;
import java.util.Map;

import javax.annotation.PostConstruct;
import javax.servlet.ServletContext;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gxp.service.SiteSettingService;

@Controller
@Scope("application")
public class GloableController {
	
	@Autowired
	private SiteSettingService siteSettingService;
	
	@Autowired
	private ServletContext servletContext;
	
	@PostConstruct  
    public void init(){
		
		Map<String, String> siteSetting = siteSettingService.getSiteSetting();
		for (Iterator<String> iter = siteSetting.keySet().iterator(); iter.hasNext(); ) {
			String key = iter.next();
			String content = siteSetting.get(key);
			servletContext.setAttribute(key, content);
		}
    }
}
